package com.javaweb.util.core;

/**
 * 线程工具类
 * @author tank2140896
 */
public class ThreadUtil {

	/**
	 * 获得当前的所有线程
	 * @return Thread[] 线程数组
	 */
	public static Thread[] getAllCurrentThread() {
		ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
		int total = Thread.activeCount();
		Thread[] currentThreadArray = new Thread[total];
		threadGroup.enumerate(currentThreadArray);
		/**
		for(Thread eachThread:currentThreadArray){
			System.out.println("线程ID："+eachThread.getId()+"，线程名称："+eachThread.getName());
			if(eachThread.getName().equals("aaa")){
				eachThread.stop();
				eachThread.interrupt();
			}
		}
		*/
		return currentThreadArray;
	}

}
